from aiocqhttp import CQHttp
import dice

import attribute_controller
import user_gen
bot = CQHttp(access_token='yowasaTest',
             enable_http_post=False)


@bot.on_message()
async def handle_msg(context):
    print(context)
    commond = context['message']
    result = None
    if commond.startswith('.r ') or commond.startswith('.rd'):
        result = dice.dice(context)
    if commond.startswith('.jrrp'):
        return
    if commond.startswith('!dnd'):
        result = attribute_controller.gen_attribute(context)
    if commond.startswith('.status'):
        result = attribute_controller.watch_attribute(context)

    if commond.startswith('.gen'):
        result = user_gen.gen(context)
    if result != None or result == '':
        await bot.send(context, result)


# @bot.on_notice('group_increase')
# async def handle_group_increase(context):
#     await bot.send(context, message='欢迎新人～',
#                    at_sender=True, auto_escape=True)
#
#
# @bot.on_request('group', 'friend')
# async def handle_request(context):
#     return {'approve': True}


bot.run(host='127.0.0.1', port=8080)
